﻿
using LxBasic;
using LxCore;

namespace LxCore.Samples
{
    public class BallRadiation : SampleVMBase
    {
        public BallRadiation() : base()
        {
            Name = "球体热辐射";
            FileName= "RadBall.msh";
        }
        public override void RunCase()
        {
            //create physical model
            var physical = LxSim.Sim.Physics.CreatePhysicalModel();
            physical.PhysicalType = PhysicalTypes.固体;
            physical.IsEnergyEnabled = true;
            physical.MaterialProperty.ThermalConductivity = new ConstField.Double(0.02);
            physical.RadiationType = RadiationTypes.DOM;

            //set zone condition
            var z = FindZone("AIR");
            ResHelper.GetCond(z).PhysicalModel = physical;

            var t_IN = FindBound(z, "WALL-IN");
            ResHelper.GetCond(t_IN).WallThermalType = WallThermalTypes.定壁温;
            ResHelper.GetCond(t_IN).Temperature = new ConstField.Double(500);

            var t_OUT = FindBound(z, "WALL-OUT");
            ResHelper.GetCond(t_OUT).WallThermalType = WallThermalTypes.定壁温;
            ResHelper.GetCond(t_OUT).Temperature = new ConstField.Double(300);

            //set monitor
            var monitor = LxSim.Sim.Monitors.CreateMonitor("内部面辐射热流", StatisticTypes.AreaIntegral);
            monitor.SetSelector(t_IN, true);
            monitor.ScalarType = ScalarFieldTypes.BoundRadiationHeatFlux;
            monitor = LxSim.Sim.Monitors.CreateMonitor("外部面辐射热流", StatisticTypes.AreaIntegral);
            monitor.SetSelector(t_OUT, true);
            monitor.ScalarType = ScalarFieldTypes.BoundRadiationHeatFlux;

            //run computation
            LxSim.Sim.Steps.IterationStep.MaxStepRule.MaxStep = 100;
            MultiThreads.SetThreadsCount(1);
            //加载到界面
        }
    }
}
